package com.wangdao.wechatmall.controller.wx;

import com.wangdao.wechatmall.bean.bo.wx.WXAddordeleteBO;
import com.wangdao.wechatmall.bean.bo.wx.WXCollectListBO;
import com.wangdao.wechatmall.bean.vo.admin.BaseRespVo;
import com.wangdao.wechatmall.bean.vo.wx.CollectListVO;
import com.wangdao.wechatmall.bean.vo.wx.WXAddordeleteFailVO;
import com.wangdao.wechatmall.bean.vo.wx.WXAddordeleteVO;
import com.wangdao.wechatmall.bean.vo.wx.WXAddressDetailVO;
import com.wangdao.wechatmall.service.admin.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ZhangXiao on 2021/7/12
 */
@RestController
@RequestMapping("wx/collect")
public class WXCollectListController {

    @Autowired
    CollectService collectService;

    @GetMapping("list")
    public BaseRespVo collectList(WXCollectListBO collectListBO) {
        CollectListVO collectListVO = collectService.selectCollectList(collectListBO);
        return BaseRespVo.ok(collectListVO);
    }

    @PostMapping("addordelete")
    public Object addordelete(@RequestBody WXAddordeleteBO wxAddordeleteBO) {
        int result = collectService.addCollect(wxAddordeleteBO);
        if (result == 1) {
            WXAddordeleteVO wxAddordeleteVO = new WXAddordeleteVO();
            wxAddordeleteVO.setType("add");
            return BaseRespVo.ok(wxAddordeleteVO);
        }else if(result==2){
            WXAddordeleteVO wxAddordeleteVO = new WXAddordeleteVO();
            wxAddordeleteVO.setType("delete");
            return BaseRespVo.ok(wxAddordeleteVO);
        }

        return WXAddordeleteFailVO.fail();

    }
}
